#pragma once

#include "Graphic2D.h"
#include "Sprite.h"
#include "Drawable.h"

namespace Core
{
	struct Size;
}

namespace Graphics
{

	enum TILE_BASE
	{
		BASE_COUNT,
		BASE_SIZE
	};

	class SpriteTile:public Sprite
	{
	private:

		TILE_BASE m_TileBase;

		// Row and col are set when initialize
		DWORD m_Row;
		DWORD m_Col;

		float m_TileW;
		float m_TileH;
		float m_TileWZ;
		float m_TileHZ;

		Core::Size* m_pSize;

	public:
		SpriteTile(DWORD col,DWORD row,Drawable* image,TILE_BASE base = BASE_COUNT);
		~SpriteTile(void);

		struct TileData
		{
			DWORD width;	// tile counts in every row
			DWORD count;	// tile counts in pData
			DWORD* pData;	// index array of tiles
			float* pStep;	// for tile text rendering, horizontal scale
		};

		// Get the tile data for rendering
		virtual const TileData& GetData(void) = 0;

		// Render the object
		virtual bool	RenderImpl(void);

		// Set the image and fix the tile size
		virtual void SetImage(Drawable* image);
		
		// Get the row and col
		DWORD GetCol(void);
		DWORD GetRow(void);
		const Core::Size& GetSize(void);

		// Get the tile base type
		TILE_BASE GetTileBase(void);

		// Set the zoom value and fix the size
		virtual void SetZoomX(float zx);
		virtual void SetZoomY(float zy);
};

}